<?php

namespace App\Http\Controllers\Api\Miniprogram;

use App\Http\Controllers\Controller;
use App\Models\System\TestLocation;
use Illuminate\Support\Facades\Log;

class TestLocationController extends Controller
{
    public function getList()
    {
        $latitude = request('latitude');
        $longitude = request('longitude');
        $list = TestLocation::where('status', 1)->get();
        if ($latitude && $longitude) {
            $list = $list->map(function ($item) use ($latitude, $longitude) {
                $item->distance = intval($item->getDistance($latitude, $longitude));
                return $item;
            });
        }
        return $this->successJson([
            'list' => $list,
        ]);
    }
}
